<template>
  <div class="preloader-bg">
    <div class="preloaderBox">
      <div class="title">
        <div class="bounce_move_1"></div>
        <div class="bounce_move_1"></div>
        <div class="bounce_move_1"></div>
        <div class="bounce_move_1"></div>
        <div class="bounce_move_1"></div>
      </div>
      <div class="preloader-bar">
        <div class="preloader-bar--loader"></div>
        <div class="preloader-bar--background"></div>
      </div>
    </div>
  </div>
  <div class="preloader-clouds">
    <div class="img-container">
      <img src="../assets/LoderAnimation/cloud-0.webp" alt="" />
    </div>
    <div class="img-container">
      <img src="../assets/LoderAnimation/cloud-1.webp" alt="" />
    </div>
    <div class="img-container">
      <img src="../assets/LoderAnimation/cloud-2.webp" alt="" />
    </div>
    <div class="img-container">
      <img src="../assets/LoderAnimation/cloud-3.webp" alt="" />
    </div>
    <div class="img-container">
      <img src="../assets/LoderAnimation/cloud-4.webp" alt="" />
    </div>
  </div>
</template>
<script setup lang="ts"></script>
<style scoped lang="scss">
@keyframes appear {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  20% {
    opacity: 1;
    transform: scale(1.2);
  }
  35% {
    transform: scale(0.9);
  }
  50% {
    transform: scale(1.08);
  }
  65% {
    transform: scale(0.96);
  }
  80% {
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
.preloader-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #ffffff;
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  .preloaderBox {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    .bounce_move_1 {
      opacity: 0;
      width: 100px;
      height: 100px;
      animation-name: appear;
      animation-duration: 1s; /* 动画持续时间为 1 秒 */
      animation-fill-mode: forwards; /* 动画结束后保留最后一帧状态 */
      &:nth-child(1) {
        background-image: url('@/assets/LoderAnimation/title1.svg');
        animation-delay: 0.2s;
      }
      &:nth-child(2) {
        background-image: url('@/assets/LoderAnimation/title2.svg');
        animation-delay: 0.3s;
      }
      &:nth-child(3) {
        background-image: url('@/assets/LoderAnimation/title3.svg');
        animation-delay: 0.4s;
      }
      &:nth-child(4) {
        background-image: url('@/assets/LoderAnimation/title4.svg');
        animation-delay: 0.5s;
      }
      &:nth-child(5) {
        background-image: url('@/assets/LoderAnimation/title5.svg');
        animation-delay: 0.6s;
      }
    }
    .preloader-bar {
      position: relative;
      width: 70%;
      -webkit-animation: 0.8s fade-in cubic-bezier(0.99, 0, 0.4, 1) forwards;
      animation: 0.8s fade-in cubic-bezier(0.99, 0, 0.4, 1) forwards;
      z-index: 1;
      background: linear-gradient(180deg, #ffffff 0%, #d9efff 100%);
      box-shadow: 0 6px #91c5e8, inset 0 -2px 10px #78cfff99;
      border-radius: 142px;
      padding: 16px;
      filter: drop-shadow(0px 10px 7px rgba(17, 24, 55, 0.21));
      margin-top: 20px;
      .preloader-bar--loader {
        position: absolute;
        top: 18px;
        left: 19px;
        width: calc(100% - 38px);
        height: 10px;
        transform-origin: left;
        border-radius: 10px;
        background: linear-gradient(180deg, #ffc806 0%, #eb7100 100%);
        box-shadow: 0 2px #d36601, inset 0 -1px 8px #fff27899;
        z-index: 1;
        width: 0;
      }
      .preloader-bar--background {
        height: 16px;
        width: 100%;
        border-radius: 10px;
        background: linear-gradient(180deg, #d5eaf8 0%, #cde7f8 100%);
        box-shadow: inset 0 2px #c2d7e6;
      }
    }
  }
  .title {
    display: flex;
  }
}
.preloader-clouds {
  position: fixed;
  height: 100vh;
  width: 100vw;
  pointer-events: none;
  background: none;
  z-index: 999;
  .img-container {
    position: absolute;
    width: 100%;
    transform: scale(2);
    img {
      width: 100%;
      height: 100%;
      width: 75%;
      transition: transform 3s;
    }
    &:nth-child(1) {
      bottom: -30%;
      left: 20%;
    }
    &:nth-child(2) {
      left: -20%;
      top: -5%;
    }
    &:nth-child(3) {
      top: -30%;
      left: -20%;
    }
    &:nth-child(4) {
      left: 60%;
      top: 0;
    }
    &:nth-child(5) {
      left: 80%;
      top: 20%;
    }
  }
  &.move {
    .img-container:nth-child(1) {
      img {
        transform: translateY(80%);
        transition-delay: 0s;
      }
    }
    .img-container:nth-child(2) {
      img {
        transform: translate(-70%);
        transition-delay: 0.1s;
      }
    }
    .img-container:nth-child(3) {
      img {
        transform: translate(90%, -80%);
        transition-delay: 0.3s;
      }
    }
    .img-container:nth-child(4) {
      img {
        transform: translateY(80%);
        transition-delay: 0s;
      }
    }
    .img-container:nth-child(5) {
      img {
        transform: translate(110%, 100%);
        transition-delay: 0.4s;
      }
    }
  }
}

.none {
  display: none;
}
</style>
